<!DOCTYPE html>
            
<HTML>
<HEAD>
<meta name="booktitle" content="Developing Applications With Objective Caml" >
 <meta charset="ISO-8859-1"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<META name="GENERATOR" content="hevea 1.05-7 of 2000-02-24">
<META NAME="Author" CONTENT="Christian.Queinnec@lip6.fr">
<LINK rel=stylesheet type="text/css" href="videoc-ocda.css">
<script language="JavaScript" src="videoc.js"><!--
//--></script>
<TITLE>
 Elements of the evaluation
</TITLE>
</HEAD>
<BODY class="regularBody">
<A HREF="book-ora198.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="index.html"><IMG SRC ="contents_motif.gif" ALT="Contents"></A>
<A HREF="book-ora200.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
<HR>

<H2> Elements of the evaluation</H2>
The Objective CAML distribution supplies two online compilers, one generating
bytecodes and the other producing instructions for the most modern
processors. The toplevel uses the bytecode compiler. Beyond that, the
distribution offers numerous libraries in the form of modules and some
tools for calculating dependencies between modules, for profiling, and for
debugging. Finally, thanks to its interface with the C language, it is
possible to link Objective CAML programs to C programs. Languages which
similarly offer an interface with C, such as the JNI (Java Native
Interface) of Java, become accessible in this way. <BR>
<BR>
The reference manual gives the language syntax, and describes the
development tools and the library signatures. This set (language, tools,
libraries, documentation) makes up a development environment.<BR>
<BR>
<A NAME="toc304"></A>
<H3> Language</H3>
<H4> Specification and implementation</H4>
There are two ways to approach a new language. A first way is to read the
language specification to have a global vision. A second is to plunge into
the language's user manual, following the concepts illustrated by the
examples. Objective CAML has neither one, which makes a self-taught approach to
it relatively difficult. The absence of a formal specification (such as
SML has) or a descriptive one (such as ADA's) is a handicap for
understanding how a program works. Another consequence of the lack of a
specification is the impossibility of getting a language standard issued by
ISO, ANSI, or IEEE. This strongly limits the construction of new
implementations tailored for other environments. Fortunately INRIA's
implementation is of high quality and best of all, the sources of the
distribution can be downloaded.<BR>
<BR>

<H4> Syntax</H4>
The particulars of syntax are a non-negligible difficulty in approaching
Objective CAML. They can be explained by the functional origin of the language,
but also by historical, that is to say anecdotal, factors.<BR>
<BR>
The syntax of application of a function to its arguments is defined by
simple juxtaposition, as in <EM>f 1 2</EM>. The lack of parentheses
bothers the neophyte as much as the C programmer or the confirmed
Lisp programmer. Nevertheless, this difficulty only arises when reading
the code of a programmer who's stingy with parentheses. Nothing stops the
neophyte Objective CAML programmer from using more explicit parenthesization and
writing <EM>(f 1 2)</EM>. <BR>
<BR>
Beyond the functional core, Objective CAML adopts a syntax sometimes at odds with
customary usage: access to array elements uses the notation <EM>t.(i)</EM>
and not the usual brackets; method invocation is noted by a pound
(# character) and not a dot, etc. These idiosyncrasies don't make it
easier to get a grip on Objective CAML.<BR>
<BR>
Finally, the syntax of Objective CAML and its ancestor Caml has undergone
numerous modifications since their first implementation. Which hasn't
pleaded in favor of the enduring nature of the developed applications.<BR>
<BR>
To end on a more positive note, the pattern-matching syntax, inherited from
the ML family, which Objective CAML incorporates, structures function definitions
by case pleasingly and with simplicity.<BR>
<BR>

<H4> Static typing</H4>
The fundamental character of the Objective CAML language resides in the
language's static typing of expressions and declarations. This guarantees
that no type error surfaces during program execution. Static type
inference was conceived for the functional languages of the ML family, and
Objective CAML has been able to maintain the greater part of this type discipline
for the imperative and object-oriented extensions. However, in the
object-oriented case, the programmer must sometimes give type inference
a hand through explicit type constraints. Still, Objective CAML preserves static
typing of expressions, and definitions, which provides an unsurpassed
measure of execution safety: an Objective CAML program, will not return the
``method not found'' exception, which is not the case for dynamically typed
object-oriented languages.<BR>
<BR>
Objective CAML's parametric polymorphism of types allows the implementation of
general algorithms. It is channeled into the object-oriented layer where
parametric classes produce generic code, and not an expansion of code as
generated by the templates of other languages. In itself, parametric
polymorphism is an important component of code reusability.<BR>
<BR>
The object-oriented extension adds a notion of inclusion polymorphism which
is obtained by specifying subtyping relationships between objects. It
reconciles code reusability, which constitutes the strength of the
inheritance relationship between classes, with the security of static
typing.<BR>
<BR>
<A NAME="toc305"></A>
<H3> Libraries and tools</H3>
The libraries supplied with the distribution cover great needs. The
programmer finds there, as a standard, the implementation of the most usual
data structures with their basic functions. For example: stacks, queues,
hash tables, AVL trees. More advanced tools can be found there as well,
such as the treatment of data streams. These libraries are enriched in the
course of successive language versions.<BR>
<BR>
The <TT>Unix</TT> library allows lower-level programming as much for I/O as
for process management. It is not identical for all platforms, which
limits its use to some extent.<BR>
<BR>
The exact arithmetic library and the regular expression library facilitate
the development of specific applications. <BR>
<BR>
Unfortunately the portable graphics library offers little functionality to
support the construction of graphical user
interfaces.<BR>
<BR>
C libraries can easily be interfaced with the Objective CAML language. 
Here, the free availability of well-structured and duly commented sources
definitely unlocks the potential for contact with the outside world and the
various and sundry libraries to be found there.<BR>
<BR>
Among the supplied tools, those for lexical and syntactic analysis,
indispensable whenever dealing with complex textual data, are especially
noteworthy. Based on the classic <TT>lex</TT> and <TT>yacc</TT>, they integrate
perfectly with sum types and the functionality of Objective CAML, thus making
them simpler to use than their predecessors.<BR>
<BR>
Finally, no matter what soundness its features may bring, use of a language
``in actual practice'' never avoids the debugging phase of a program. The
Objective CAML 2.04 distribution does not supply an IDE. Certainly, using the
toplevel allows one to proceed rapidly to compilation and unit tests of
functions (which is an undeniable advantage), but this usage will vary by
platform and by programmer: cut-and-paste under X-Windows, calling the
shell under <TT>emacs</TT>, requesting evaluation of a buffer under
Windows. The next version (see appendix <A HREF="index.html#chap-NewOcaml">B</A>) provides
for the first time an environment for Unix containing a browser for
interfaces and modules and a structured editor linked to the toplevel.
Finally the distribution's debugger remains hard to use (in particular,
because of the functional aspect and the language's parametric
polymorphism) and limited to the Unix system.<BR>
<BR>
<A NAME="toc306"></A>
<H3> Documentation</H3>
The documentation of the distribution consists of the reference manual in
printable (PostScript) and online (HTML) format. This manual is not in any
case an introduction to the language. On the contrary it is indispensable
for finding out what's in the libraries or what parameters the commands
take. Some pedagogical material can be found on Inria's Caml page,
but it is mostly regarding the Caml-Light language. Thus the language is
missing a complete tutorial manual, we hope that this book fills this gap.<BR>
<BR>
<HR>
<A HREF="book-ora198.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="index.html"><IMG SRC ="contents_motif.gif" ALT="Contents"></A>
<A HREF="book-ora200.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
</BODY>
</HTML>
